package jt.example.tabview;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.TabHost;

/**
 * Created by TaoJn on 4/3/2016.
 */
public class MainActivity extends Activity {

    private TabHost tabHost;

    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);

        this.setContentView(R.layout.main);

        // NOTE: this is android.R.id.tabhost not R.id.tabhost
        tabHost = (TabHost) this.findViewById(android.R.id.tabhost);
        tabHost.setup();

        LayoutInflater inflater = LayoutInflater.from(this);

        inflater.inflate(R.layout.tab_call_in, tabHost.getTabContentView());
        inflater.inflate(R.layout.tab_call_out, tabHost.getTabContentView());
        inflater.inflate(R.layout.tab_not_received, tabHost.getTabContentView());

        tabHost.addTab(tabHost.newTabSpec("tab01").setIndicator("未接来电").setContent(R.id.notReceivedTab));
        tabHost.addTab(tabHost.newTabSpec("tab02").setIndicator("打进").setContent(R.id.tabCallIn));
        tabHost.addTab(tabHost.newTabSpec("tab03").setIndicator("打出").setContent(R.id.tabCallOut));
    }
}
